import request from '@/utils/request'

/**
 * 订单服务
 * @type {{shipOrder: (function(*=): *), cancelOrder: (function(*=): *), confirmReceiveShopKeeper: (function(*=): *), listOrder: (function(*): *), getOrder: (function(*=): *)}}
 */
export const OrderService = {
  // 订单列表
  listOrder: function(query) { return request({ method: 'get', url: '/manage/order/list.do', params: { ...query }}) },
  // 订单详情
  getOrder: function(orderNo) { return request({ method: 'get', url: '/manage/order/detail.do', params: { orderNo: orderNo }}) },
  // 取消订单
  cancelOrder: function(form) { return request({ method: 'get', url: '/manage/order/cancel.do', params: form }) },
  // 发货
  shipOrder: function(shipForm) { return request({ method: 'post', url: '/manage/order/ship.do', data: shipForm }) },
  // 商家确认收货
  confirmReceiveShopKeeper: function(orderNo) { return request({ method: 'get', url: '/manage/order/confirm/receive.do', params: { orderNo: orderNo }}) }
}

/**
 * 退款单服务
 * @type {{rejectOrderRefund: (function(*=): *), listOrderRefund: (function(*): *), refundOrder: (function(*=): *), agreeOrderRefund: (function(*=): *)}}
 */
export const RefundOrderService = {
  // 退款单列表
  listOrderRefund: function(query) { return request({ method: 'get', url: '/manage/refund/list.do', params: { ...query }}) },
  // 同意退款申请
  agreeOrderRefund: function(refundNo) { return request({ method: 'get', url: '/manage/refund/agree.do', params: { refundNo: refundNo }}) },
  // 驳回退款申请
  rejectOrderRefund: function(params) { return request({ method: 'get', url: '/manage/refund/reject.do', params: params }) },
  // 退款操作
  refundOrder: function(params) { return request({ method: 'post', url: '/manage/refund/process.do', data: params }) }
}
